@echo off

set aa="aaaaaaaaaaaaaaabaaabaaaabaaa"
set bb=%aa:b=c%
echo %bb%



set rootpath=%~dp0
for /r %rootpath% %%p in (.) do ( 
    for  %%i in (%%~fp\*.proto) do (   
        set file=%%i
        set file=%file:%%rootpath%%= %
        echo "ddddddddddddddddd" %file%
        goto :eof
        
        set file=%file:\=/%
        
        set dir=%%~fp
        set dir=%dir:\=/%
        
        set filename=%%~ni
        set protofile_t=""
        set hfile_t=""
        
        for %%f in ( %%~fp\%%~ni.pb.h  %%~fp\%%~ni.proto  ) do (
            if "%%~xf" == ".proto" set protofile_t=%%~tf
            if "%%~xf" == ".h" set hfile_t=%%~tf
        )
        echo "%protofile_t%" gtr "%hfile_t%"
        
        if "%protofile_t%" gtr "%hfile_t%"  (
            echo protoc.exe --proto_path="%dir%" --cpp_out="%dir%" "%file%"
            protoc.exe --proto_path="%dir%" --cpp_out="%dir%" "%file%"
        )
        
        set protofile2_t=""
        set luafile_t=""
        
        for %%t in ( %%~fp\%%~ni_pb.lua  %%~fp\%%~ni.proto  ) do (
            if "%%~xt" == ".proto" set protofile2_t=%%~tt
            if "%%~xt" == ".lua" set luafile_t=%%~tt
        )
        echo "%protofile2_t%" gtr "%luafile_t%"
        
        if "%protofile2_t%" gtr "%luafile_t%"  (
            echo "protoc.exe --lua_out=%%~fp --plugin=protoc-gen-lua=%rootpath%/protoc-gen-lua.bat --proto_path=%%~fp %%i"
            rem protoc.exe --lua_out=%%~fp --plugin=protoc-gen-lua=%rootpath%/protoc-gen-lua.bat --proto_path=%%~fp %%i
        )
    )
)

